<include file="./admin-header" />

	<!-- BEGIN PAGE -->
	<div class="page-content">
		<!-- BEGIN PAGE HEADER-->
		<div class="row">
			<div class="col-md-12">
				<!-- BEGIN PAGE TITLE & BREADCRUMB-->
				<h3 class="page-title">{$Think.lang.text_role_management} <small>{$Think.lang.text_role_management_tips_en}</small></h3>
				<ul class="page-breadcrumb breadcrumb">
					<li class="btn-group">
						<button type="button" class="btn blue dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true">
							<span>{$Think.lang.text_roles}</span><i class="fa fa-angle-down"></i>
						</button>
						<ul class="dropdown-menu pull-right" role="menu">
							<!-- <volist name="authgroup" id="groups"> -->
							<li>
								<a href="{:U('access',array('id'=>$groups['id']))}">
								<if condition="$groups['id'] eq $group['id']"><font color="red">{$groups['title']}</font><else />{$groups['title']}</if></a>
							</li>
							<!-- </volist> -->
						</ul>
					</li>
					<li>
						<i class="fa fa-home"></i> <a href="{:U('Index/index')}">{$Think.lang.text_home}</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="{:U('User/index')}">{$Think.lang.text_user}</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="{:U('index')}">{$Think.lang.text_role_management}</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li><a href="{:U('access')}">{$Think.lang.text_role_auth_access}</a> </li>
				</ul>
				<!-- END PAGE TITLE & BREADCRUMB-->
			</div>
		</div>
		<!-- END PAGE HEADER--> 
		<!-- BEGIN PAGE CONTENT-->
		<form name="myform" id="myform" action="{:U('updateGroup')}" method="post">
		<input type="hidden" name="id" value="{$group['id']}" /> 
			<!-- <volist name="nodelist" id="node" key="k"> -->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN SAMPLE TABLE PORTLET-->
					<div class="portlet box blue">
						<div class="portlet-title">
							<div class="caption">
								<input type="checkbox" id="toprules_{$k}" class="auth_rules" name="rules[]" value="{$mainrules[$node['url']]}" onclick="selectBox('{$k}');" />{$node['title']}
							</div>
							<div class="tools">
								<a href="javascript:;" class="collapse"></a> 
								<a href="javascript:;" class="reload"></a>
							</div>
						</div>
						<div class="portlet-body">
						<dl class="checkmod">
							<dd class="bd">
								<present name="node['child']"> 
								<!-- <volist name="node['child']" id="child"> -->
								<div class="rule_check_{$k}">
									<label class="checkbox" <notempty name="child['description']">title='{$child['description']}'</notempty>>
										<input class="auth_rules" id="child_rule_{$child[id]}" type="checkbox" name="rules[]" value="{$childrule[$child['url']]}" onclick="selectChild('{$child[id]}','{$k}');" /> {$child['title']}
									</label> 
									<notempty name="child['operator']">
										<div class="check_laster child_{$child[id]}">
										<!-- <volist name="child['operator']" id="op"> -->
										<label class="checkbox"<notempty name="op['description']">title='{$op['description']}'</notempty>>
										<input class="auth_rules" type="checkbox" name="rules[]" value="{$childrule[$op['url']]}" /> {$op['title']}</label> 
										<!-- </volist> -->
										</div>
									</notempty>
								</div>
								<!-- </volist> --> 
								</present>
							</dd>
						</dl>
						</div>
					</div>
					<!-- END SAMPLE TABLE PORTLET-->
				</div>
			</div>
			<!-- </volist> -->
			<div class="row">
				<div class="col-md-12">
					<div class="col-md-offset-3 col-md-9">
						<button type="submit" name="dosubmit" class="btn blue">
						<i class="fa fa-check"></i> {$Think.lang.button_submit}</button>
					</div>
				</div>
			</div>
		</form>
		<!-- END PAGE CONTENT-->
	</div>
	<!-- END PAGE -->
	<include file="./admin-js" />
	<script>
		jQuery(document).ready(function() {
		   App.init();
		});
		$(function(){
			var rules = [{$group.rules}];
			$('.auth_rules').each(function(){
				if(jQuery.inArray(parseInt(this.value),rules)>-1){
					$(this).parent("span").attr('class','checked');
					$(this).parent("span").find(".auth_rules").attr('checked','checked');
				}
			});
		});
		function selectBox(kid){   //全选节点
			if($("#toprules_"+kid).prop("checked")){
				$(".rule_check_"+kid).each(function(){
					 $(this).find("span").attr('class','checked');
					 $(this).find("span").find(".auth_rules").attr('checked','checked');
				})
			}else {
				$(".rule_check_"+kid).each(function(){
					 $(this).find("span").attr('class','');
					 $(this).find("span").find(".auth_rules").removeAttr('checked');
				})
			}
		}
		function selectChild(cid,k){
			if($("#child_rule_"+cid).prop("checked")){
				$("#toprules_"+k).parent("span").attr('class','checked');
				$(".child_"+cid).each(function(){
					$(this).find("span").attr('class','checked');
					$(this).find("span").find(".auth_rules").attr('checked','checked');
				})
			}else{
				$(".child_"+cid).each(function(){
					$(this).find("span").attr('class','');
					 $(this).find("span").find(".auth_rules").removeAttr('checked');
				})
			}
		}
	</script>

<include file="./admin-footer" />